package com.example.myblog_ssm.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22479
 * Date: 2023-03-21
 * Time: 8:52
 */

/**
 * 启动登录拦截器
 */
@Configuration //启动拦截器 随着spring项目启动
public class MvcConfigurer implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/img/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/css/**")
                .excludePathPatterns("/editor.md/**")
                .excludePathPatterns("/user/login")
                .excludePathPatterns("/user/reg")
                .excludePathPatterns("/login.html")
                .excludePathPatterns("/reg.html")
                .excludePathPatterns("/blog_list.html")
                .excludePathPatterns("/blog_content.html")
                .excludePathPatterns("/art/detail")
                .excludePathPatterns("/user/getuserbyid")
                .excludePathPatterns("/art/incr-rcoun")
                .excludePathPatterns("/art/add")
                .excludePathPatterns("/art/update")
                .excludePathPatterns("/art/listbypage")
                .excludePathPatterns("/comment/putcomment")
                .excludePathPatterns("/comment/getcomment")
                .excludePathPatterns("/user/findpsw")
                .excludePathPatterns("/blog_forgetpsw.html")
                .excludePathPatterns("/img");
    }
}
